/*
 * Copyright (C) 2017 Pingan, Inc. All Rights Reserved.
 */
package com.pingan.haofang.searchcloud.api.schema;

/**
 * @author huhailiang937
 * @date 2017年5月3日下午9:01:07
 * @since 1.0.0
 */
public class SchemaField {

    /**
     * 字段名称
     */
    protected String name;
    
    /**
     * 字段类型在Solr类型名称
     */
    protected String type;
    
    /**
     * 是否索引
     */
    protected boolean indexed = true;
    
    /**
     * 是否存储
     */
    protected boolean stored = true;
    
    /**
     * 是否必填，不能为空
     */
    protected boolean required = false;
    
    /**
     * 字段设置一个默认值，防止为空 
     */
    protected String defaultValue;
    
    /**
     * 是否多值
     */
    protected boolean multiValued = false;
    
    /**
     * 是否是主键
     */
    protected boolean uniqueKey = false;
    
    
    /**
     * 如果这个字段应该有文档值（doc values），设置为true
     */
    protected boolean docValues = false;
    
    /**
     * 字段备注
     */
    protected String remarks;
    
    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public String getType() {
        return type;
    }

    public void setType(String type) {
        this.type = type;
    }

    public String getDefaultValue() {
        return defaultValue;
    }

    public void setDefaultValue(String defaultValue) {
        this.defaultValue = defaultValue;
    }

    public boolean isIndexed() {
        return indexed;
    }

    public void setIndexed(boolean indexed) {
        this.indexed = indexed;
    }

    public boolean isStored() {
        return stored;
    }

    public void setStored(boolean stored) {
        this.stored = stored;
    }

    public boolean isRequired() {
        return required;
    }

    public void setRequired(boolean required) {
        this.required = required;
    }

    public boolean isMultiValued() {
        return multiValued;
    }

    public void setMultiValued(boolean multiValued) {
        this.multiValued = multiValued;
    }

    public boolean isDocValues() {
        return docValues;
    }

    public void setDocValues(boolean docValues) {
        this.docValues = docValues;
    }

    public String getRemarks() {
        return remarks;
    }

    public void setRemarks(String remarks) {
        this.remarks = remarks;
    }

    /* (non-Javadoc)
     * @see java.lang.Object#hashCode()
     */
    @Override
    public int hashCode() {
        final int prime = 31;
        int result = 1;
        result = prime * result + ((name == null) ? 0 : name.hashCode());
        return result;
    }

    /* (non-Javadoc)
     * @see java.lang.Object#equals(java.lang.Object)
     */
    @Override
    public boolean equals(Object obj) {
        if (this == obj)
            return true;
        if (obj == null)
            return false;
        if (getClass() != obj.getClass())
            return false;
        SchemaField other = (SchemaField) obj;
        if (name == null) {
            if (other.name != null)
                return false;
        } else if (!name.equals(other.name))
            return false;
        return true;
    }

    /**
     * @return the uniqueKey
     */
    public boolean isUniqueKey() {
        return uniqueKey;
    }

    /**
     * @param uniqueKey the uniqueKey to set
     */
    public void setUniqueKey(boolean uniqueKey) {
        this.uniqueKey = uniqueKey;
    }

}
